package com.example.famhealing.schedule;

import java.util.ArrayList;

import com.example.famhealing.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
 
public class MeditationListAdapter extends ArrayAdapter<Meditation_List_Data> {
 
    private ArrayList<Meditation_List_Data> items;
 
    public MeditationListAdapter(Context context, int textViewResourceId,
            ArrayList<Meditation_List_Data> items) {
        super(context, textViewResourceId, items);
        this.items = items; }
 
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;
        if (v == null) {
            
            LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
                    Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.meditation_list, null);
        }
        Meditation_List_Data meditation_list_data = items.get(position);
 
        if (meditation_list_data != null) {
            //하나의 이미지뷰와 2개의 텍스트뷰 정보를 받아온다.
            TextView tv_medicine = (TextView) v.findViewById(R.id.medicine);
            TextView tv_day = (TextView) v.findViewById(R.id.day);
            TextView tv_time = (TextView) v.findViewById(R.id.time);
            
            // 현재 item의 position에 맞는 이미지와 글을 넣어준다.         
            
            tv_medicine.setText(meditation_list_data.getMedicine());
            tv_day.setText(meditation_list_data.getMeditationDay());
            tv_time.setText(meditation_list_data.getMeditationTime());
            
        }
 
        return v;
    }
}
 
class Meditation_List_Data {
    private String medicine;
    private String meditationDay;
    private String meditationTime;
 
    public Meditation_List_Data(String medicine, String meditationDay
    		, String meditationTime) {
        this.setMedicine(medicine);
        this.setMeditationDay(meditationDay);
        this.setMeditationTime(meditationTime);
    }
 
    public String getMedicine() {
        return medicine;
    }
 
    public void setMedicine(String medicine) {
        this.medicine = medicine;
    }
 
    public String getMeditationDay() {
        return meditationDay;
    }
 
    public void setMeditationDay(String meditationDay) {
        this.meditationDay = meditationDay;
    }
    
    public String getMeditationTime() {
        return meditationTime;
    }
 
    public void setMeditationTime(String meditationTime) {
        this.meditationTime = meditationTime;
    }
    
}